﻿/*
*   This file is part of NSMB Editor 5.
*
*   NSMB Editor 5 is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*
*   NSMB Editor 5 is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with NSMB Editor 5.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace NSMBe4
{
    public partial class TilesetChooser : Form
    {
        public TilesetChooser()
        {
            InitializeComponent();
            if (Properties.Settings.Default.mdi)
                this.MdiParent = MdiParentForm.instance;
            LanguageManager.ApplyToContainer(this, "TilesetChooser");

            // Add tilesets to list
            int index = 0;
            string[] parsedlist = new string[76];
            foreach (string name in LanguageManager.GetList("Tilesets")) {
                string trimmedname = name.Trim();
                if (trimmedname == "") continue;
                parsedlist[index] = trimmedname;
                index += 1;
            }

            tilesetComboBox.Items.AddRange(parsedlist);
            this.Icon = Properties.Resources.nsmbe;
        }

        private void editJyotyuButton_Click(object sender, EventArgs e) {
            try
            {
                new TilesetEditor(65535, "Jyotyu").Show();
            }
            catch (AlreadyEditingException)
            {
                MessageBox.Show(LanguageManager.Get("Errors", "Tileset"));
            }
            Close();
        }

        private void editNoharaSubButton_Click(object sender, EventArgs e) {
            try
            {
                new TilesetEditor(65534, "Nohara SubUnit").Show();
            }
            catch (AlreadyEditingException)
            {
                MessageBox.Show(LanguageManager.Get("Errors", "Tileset"));
            }
            Close();
        }

        private void openTilesetButton_Click(object sender, EventArgs e) {
            try
            {
                new TilesetEditor((ushort)tilesetComboBox.SelectedIndex, (string)tilesetComboBox.SelectedItem).Show();
            }
            catch (AlreadyEditingException)
            {
                MessageBox.Show(LanguageManager.Get("Errors", "Tileset"));
            }
            Close();
        }

        private void tilesetComboBox_SelectedIndexChanged(object sender, EventArgs e) {
            openTilesetButton.Enabled = true;
        }
    }
}
